import socket


def sent_data(conn: socket.socket, data: str):
    header = len(data).to_bytes(4, byteorder="big")

    message = header + data.encode()

    conn.sendall(message)


def recv_data(conn: socket.socket):
    header = conn.recv(4)

    data_len = int.from_bytes(header, byteorder="big")

    data = conn.recv(data_len).decode()

    return data
